package com.file;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.*;

/**
 * @author: cxt
 * @time: 2022/8/16
 */
@RestController
@RequestMapping("/api/file")
public class FilesController {

    @GetMapping("/get")
    public String getFilePath() {

        return "请求成功";
    }

    public static void main(String[] args) throws IOException {
        File file = new File("E://code.json");
        BufferedReader reader = new BufferedReader(new FileReader(file));

        File newFile = new File("E://newCode.json");
        BufferedWriter writer = new BufferedWriter(new FileWriter(newFile, true));

        String line;
        while ((line = reader.readLine()) != null) {
            String[] split = line.split("@");
            String code = split[0].trim();
            String name = split[1].replaceAll(" ", "").trim();
            String str = "\"" + code + "\":\"" + name + "\",";
            writer.write(str);
            writer.write("\r\n");
        }

        reader.close();
        writer.close();
    }

}
